package mrusanov.sounds

import xml.XML
import java.io.File

object SoundConfigLoader {
   private val PATH_TO_SOUNDS = "/data/sounds/"

   lazy val soundsMap = loadSounds

   private def loadSounds:Map[String, Sound] = {
     val path = getClass.getResource("/conf/sounds.xml").toURI
     val xml = XML.loadFile(new File(path))

     val sounds = for (node <- xml \ "sound") yield {
       val name = (node \ "@name").toString()
       val path = PATH_TO_SOUNDS + (node \ "@path").toString()
       (name, new Sound(path))
     }

     sounds.toMap
   }
}
